#include "..//include//createvfs.h"
#include <stdio.h>
#include <string.h>

int unmntvfs (char label[], char filename_g[]) {
	
	char name[30] = "";
	int pos = 0,i;
	
	if (strcmp(label,"") == 0) {
		// VFS_INSUFFICIENT_ARGUMENTS
		printf("unmountvfs_FAILURE %s\n",ERR_VFS_UNMOUNT_00);
		return 0;
	}

	for( i = 0 ; i < strlen(filename_g) ; i++){
		if(filename_g[i]=='.' || filename_g[i]=='\0') 
      		break;
      		pos++;
   	}
   	
   	for(i=0;i<pos;i++) {
   		name[i] = filename_g[i];
   	}
	
	if (strcmp(label,name) != 0) {
		// VFS NOT MOUNTED
		printf("unmountvfs_FAILURE %s\n",ERR_VFS_UNMOUNT_03);
		return 0;
	} 
	
	FILE *fp2 = fopen(filename_g, "rb+");
	if(fp2 == NULL) {
		printf("unmountvfs_FAILURE %s\n",ERR_VFS_UNMOUNT_01);
		return 0;
	}

	return 1;
}
